/* 
 * Copyright 2007 Steven Osborn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.lenovo.leos.filebrowser.ui;

import java.io.File;
import java.util.ArrayList;

import android.graphics.drawable.Drawable;
import android.util.Log;

/** @author Steven Osborn - http://steven.bitsetters.com */
public class IconifiedText implements Comparable<IconifiedText>{
    
	private static final String TAG = "IconifiedText";
	private static final boolean TAG_FLAG = false;
	private String mText = "";
	private Drawable mIcon;
	private File Tfile = null;
	private  boolean isCut = false;
	private boolean isSysDir = false;
	public ArrayList<String> mPinyin = null;
	
	public IconifiedText(Drawable bullet,File file, boolean isSysDir) {
		if (TAG_FLAG){
			Log.d(TAG, "bullet============================="+bullet);
			Log.d(TAG, "file============================="+file);
			Log.d(TAG, "isSysDir============================="+isSysDir);
		}
		mIcon = bullet;
		mText = file.getName();
		Tfile = file;
		this.isSysDir = isSysDir;
		
		if(FileBrowser.MarkedFile.contains(file)){
			//if the file is selected and to be cut, set is cut flag to ture. 
			if(FileBrowser.cut_copy && FileBrowser.opType == FileBrowser.OPTYPE.CUT){
				setIsCut(true);
			}
		}
	}
	
	public boolean isSysDir(){
		return isSysDir;
	}
	
	public void setIsCut(boolean iscut){
		isCut = iscut;
	}
	
	public boolean getIsCut(){
		return isCut;
	}
	
	public File getFile(){
		return this.Tfile;
	}

	public String getText() {
		return mText;
	}
	
	public void setTextPy(String sPy){
		String[] pyList = sPy.split(" ");
		if(mPinyin == null)
			mPinyin = new ArrayList<String>();
		
		for(int i=0; i<pyList.length; i++){
			mPinyin.add(pyList[i]);
		}
	}
	
	public int getPyCount(){
		if(mPinyin == null)
			return 0;
		
		return mPinyin.size();
	}
	
	public ArrayList<String> getAllPy(){
		return mPinyin;
	}
	
	public String getCharPy(int index){
		if(mPinyin == null || index >= mPinyin.size())
			return null;
		
		return mPinyin.get(index);
	}
	
	public void appendPy(String sPy){
		if(mPinyin == null)
			mPinyin = new ArrayList<String>();
		
		mPinyin.add(sPy);
	}
	
	public void setText(String text) {
		mText = text;
	}
	
	public void setIcon(Drawable icon) {
		mIcon = icon;
	}
	
	public Drawable getIcon() {
		return mIcon;
	}

	//@Override
	public int compareTo(IconifiedText other) {
		if(this.mText != null)
			return this.mText.compareTo(other.getText()); 
		else 
			throw new IllegalArgumentException();
	}
}
